<template>
  <div>
    <!-- 经销商名称\代码搜索 -->
    <TopFilter
      :list="topFilterInit"
      :cols="3"
      :collapse="collapse"
      labelWidth="90"
      @filterChange="changeHandle"
    ></TopFilter>
    <!-- table -->
    <FilterTable
      height="250"
      ref="listModal"
      :columns="columns"
      :fetchapi="fetchParams"
      :params="flterValue"
      :datakey="'records'"
      :onColumnsChange="columns => this.columns = columns"
    ></FilterTable>
    <div class="dialogBottmView">
      <el-button @click="closeDialog">取 消</el-button>
      <el-button @click="saveDialog" type="primary">{{submit}}</el-button>
    </div>
  </div>
</template>
<script>
import { dictionary } from '@/utils/dictMixin';
export default {
  mixins: [dictionary],
  props: {
    submit: {
      type: String,
      default: '确定'
    }
  },
  data() {
    return {
      visible: false,
      visibleDrawer: false,
      collapse: false,
      infoId: null,
      topFilterInit: this.topFilterInitFun(),
      flterValue: {}, //参数
      columns: this.creatHeader(),
      fetchParams: null //ipa 接口
    };
  },
  methods: {
    //搜索数据
    topFilterInitFun() {
      return [
        { type: 'INPUT', label: '经销商代码', fieldName: 'field2', placeholder: '请输入', initialValue: '' },
        { type: 'INPUT', label: '经销商名称', fieldName: 'field3', placeholder: '请输入', initialValue: '' }
      ];
    },
    //搜索获取数据
    changeHandle(val) {
      this.flterValue = val;
      console.log(val);
    },
    //table表头和数据源
    creatHeader() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 80,
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        { title: '公司全称', dataIndex: 'field0', sorter: true },
        { title: '经销商代码', dataIndex: 'field1', sorter: true },
        { title: '经销商简称', dataIndex: 'field2', sorter: true },
        { title: '经销商类型', dataIndex: 'field3', sorter: true },
        { title: '经销商级别', dataIndex: 'field4', sorter: true },
        { title: '事业部', dataIndex: 'field5', sorter: true },
        { title: '省份', dataIndex: 'field6', sorter: true },
        { title: '城市', dataIndex: 'field7', sorter: true },
        { title: '县区', dataIndex: 'field8', sorter: true }
      ];
    },
    //保存
    saveDialog() {
      this.$emit('close', { visible: false });
    },
    //取消操作
    closeDialog() {
      this.$emit('close', { visible: false });
    }
  }
};
</script>

<style lang="less" scoped>
</style>
